﻿project(CuLibDGGSKernel CXX CUDA)
set(CMAKE_CUDA_ARCHITECTURES native)

#set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)

find_package(CUDA REQUIRED)
enable_language(CUDA)

# 设置 C++ 和 CUDA 标准
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CUDA_STANDARD 17)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)

set(CMAKE_OUT_DIR ${CMAKE_SOURCE_DIR})

set(lib_install_directory ${CMAKE_SOURCE_DIR}/out)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_OUT_DIR}/out/build/CuDGGS/CuLibDGGSKernel)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_OUT_DIR}/out/build/CuDGGS/CuLibDGGSKernel)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_OUT_DIR}/out/build/CuDGGS/CuLibDGGSKernel)

include_directories(${CMAKE_SOURCE_DIR}/3rdlibs/include)

set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

add_library(CuLibDGGSKernel STATIC
        ISEA4H/ISEA4HImpl.cu
        Projection/Project.cu
        ISEA4D/ISEA4DImpl.cu
        ISEA4T/ISEA4TImpl.cu
        LibCuDGGSKernel.cu
)

target_compile_definitions(CuLibDGGSKernel PRIVATE BUILDING_DLL)

set_target_properties(CuLibDGGSKernel PROPERTIES CUDA_SEPARABLE_COMPILATION ON)


set(ISEXTRACT ON)
if(ISEXTRACT)
    file(GLOB_RECURSE MyLIB_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/*Kernel*.cuh")
    foreach(header_file ${MyLIB_HEADERS})
        get_filename_component(header_dir ${header_file} DIRECTORY)
        string(REPLACE ${CMAKE_CURRENT_SOURCE_DIR} ${lib_output_directory}/include/CuLibDGGSKernel output_header_dir ${header_dir})
        file(MAKE_DIRECTORY ${output_header_dir})
        configure_file(${header_file} ${output_header_dir} COPYONLY)
    endforeach()

    add_custom_command(TARGET CuLibDGGSKernel POST_BUILD
            COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_LINKER_FILE:CuLibDGGSKernel>" "${lib_output_directory}/lib/"
    )
endif()

















# Ensure the target is correctly linked
target_link_libraries(CuLibDGGSKernel PRIVATE cudart_static)



